package com.flying.ouyu.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.flying.client.utils.Logger;
import com.flying.ouyu.OuyuApplication;
import com.flying.ouyu.R;
import com.flying.ouyu.base.BaseActivity;
import com.flying.ouyu.tool.ResourceManager;
import com.flying.ouyu.view.model.LoginView;

public class LoginActivity extends BaseActivity {
	private static final Logger logger = Logger.getLogger(LoginActivity.class.getName());
	
	private LoginView loginView;
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState, R.layout.act_login);
		
		createLoginView();
		
		initLoginView();
		
		bindEventOnView();
	}
	/**
	 * 创建Activity控件
	 */
	private void createLoginView()
	{
		loginView = new LoginView(this);
	}
	/**
	 * 初始化Activity控件
	 */
	private void initLoginView()
	{
		loginView.topBar.txtTitle.setText(ResourceManager.getString(R.string.login));
	}
	/**
	 * 绑定事件
	 */
	private void bindEventOnView()
	{
		loginView.topBar.btnGoBack.setOnClickListener(goBackClick);
		
		loginView.btnLogin.setOnClickListener(loginClick);
		loginView.btnForgetPasswrod.setOnClickListener(forgetPwdClick);
	}
	
	/**
	 * 登录
	 */
	private View.OnClickListener loginClick = new View.OnClickListener()
	{
		public void onClick(View v) {
			logger.debug("login");
		}
	};
	/**
	 * 忘记密码
	 */
	private View.OnClickListener forgetPwdClick = new View.OnClickListener()
	{
		public void onClick(View v) {
			logger.debug("forget password");
		}
	};
	/**
	 * 开始登录Activity
	 */
	public static void startLoginActivity()
	{
		Intent intent = new Intent(OuyuApplication.getInstance(),LoginActivity.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
		
		OuyuApplication.getInstance().startActivity(intent);
	}
}
